/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hello;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.Ticker;
import java.io.*;
import javax.microedition.io.*;

/**
 * @author monitor
 */
public class HelloMIDlet extends MIDlet implements CommandListener, ItemCommandListener {

    private boolean midletPaused = false;
    //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
    private Command exitCommand;
    private Command login;
    private Command ok;
    private Command voltarMesa;
    private Command entrarMesa;
    private Command exitCommand1;
    private Command adicionarProduto;
    private Command voltarVendas;
    private Command finalizarVendas;
    private Command voltarInicio;
    private Command okEntrar;
    private Command enviarParcial;
    private Command enviarConta;
    private Command voltarConta;
    private Command voltarParcial;
    private Command itemCommand;
    private Command voltarEnviar;
    private Command okCommand;
    private Command alterarQuantidade;
    private Command voltarEnviar1;
    private Command enviarProduto;
    private Command excluirProduto;
    private Command voltarLista;
    private Command alterar1;
    private Command alterar;
    private Command excluir;
    private Command voltarAlterar;
    private Form formLogin;
    private TextField senhaGarcon;
    private TextField numeroGarcon;
    private Form formMesa;
    private TextField mesa;
    private StringItem numGarcon2;
    private Form formInicio;
    private StringItem fecharConta;
    private StringItem numGarcon1;
    private StringItem fecharParcial;
    private StringItem fazerPedido;
    private Form formVendas;
    private StringItem numMesaVend;
    private TextField qtd;
    private TextField produto;
    private StringItem p1;
    private Form formConta;
    private TextField garconConta;
    private TextField mesaConta;
    private TextField pessoasConta;
    private Form formParcial;
    private TextField garconParcial;
    private TextField mesaParcial;
    private Form formEnviar;
    private StringItem p2;
    private Form formAlterar;
    private StringItem prodAlter;
    private TextField newQtd;
    private List lista;
    private Ticker ticker;
    //</editor-fold>//GEN-END:|fields|0|
    private String addProduto = "";
    public String p[] = {"", "", "", "", "", "", "", "", "", ""};
    public String q[] = {"", "", "", "", "", "", "", "", "", ""};
    public int j = 0;
    public int total;
    /**
     * The HelloMIDlet constructor.
     */
    public String pdt = "";

    public HelloMIDlet() {
    }

    //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
    //</editor-fold>//GEN-END:|methods|0|
    //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize
    /**
     * Initializes the application.
     * It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
     */
    private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize
        // write pre-initialize user code here
//GEN-LINE:|0-initialize|1|0-postInitialize
        // write post-initialize user code here
    }//GEN-BEGIN:|0-initialize|2|
    //</editor-fold>//GEN-END:|0-initialize|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Started point.
     */
    public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction
        // write pre-action user code here
        switchDisplayable(null, getFormLogin());//GEN-LINE:|3-startMIDlet|1|3-postAction
        // write post-action user code here
    }//GEN-BEGIN:|3-startMIDlet|2|
    //</editor-fold>//GEN-END:|3-startMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Resumed point.
     */
    public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction
        // write pre-action user code here
//GEN-LINE:|4-resumeMIDlet|1|4-postAction
        // write post-action user code here
    }//GEN-BEGIN:|4-resumeMIDlet|2|
    //</editor-fold>//GEN-END:|4-resumeMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
    /**
     * Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
     * @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
     * @param nextDisplayable the Displayable to be set
     */
    public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch
        // write pre-switch user code here

        Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
        if (alert == null) {
            display.setCurrent(nextDisplayable);
        } else {
            display.setCurrent(alert, nextDisplayable);
        }//GEN-END:|5-switchDisplayable|1|5-postSwitch
        // write post-switch user code here
    }//GEN-BEGIN:|5-switchDisplayable|2|
    //</editor-fold>//GEN-END:|5-switchDisplayable|2|
    //pega os códigos digitados e troca por nomes dos produtos

    public String codigos(String prod) {
        int prod2 = Integer.parseInt(prod);
        switch (prod2) {
            case 2333:
                return "agua s/ gás";
            case 1888:
                return "batata";
            case 1919:
                return "patinha de caranguejo";
            case 1920:
                return "pargo inteiro";
            case 99532:
                return "pepsi";
            case 99007:
                return "copo limpo";
            case 99008:
                return "prato limpo";
            default:
                return "falso";
        }
    }
    //verifica se o garçon e a senha existem

    public boolean isValidar(String garcon, String senha) {
        int numG = Integer.parseInt(garcon);
        try {
            switch (numG) {
                case 38:
                    if (senha.equals("aabc")) {
                        return true;
                    }
                case 11:
                    if (senha.equals("defd")) {
                        return true;
                    }
                case 22:
                    if (senha.equals("2213")) {
                        return true;
                    }
                case 33:
                    if (senha.equals("6941")) {
                        return true;
                    }
                case 24:
                    if (senha.equals("teste")) {
                        return true;
                    }
                default:
                    return false;
            }
        } catch (Exception ex) {
            System.out.println("Execeção Isvalidar" + ex.getMessage());
            return false;
        }
    }

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction
    /**
     * Called by a system to indicated that a command has been invoked on a particular displayable.
     * @param command the Command that was invoked
     * @param displayable the Displayable where the command was invoked
     */
    public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction
        // write pre-action user code here
        Alert alertaLogin, alertaGarSen, alertaMesa, alertaCodigo, alertaProduto, alertaQtd;
        if (displayable == formAlterar) {//GEN-BEGIN:|7-commandAction|1|141-preAction
            if (command == alterar1) {//GEN-END:|7-commandAction|1|141-preAction
                // write pre-action user code here
                String valor = newQtd.getString();
                pdt += prodAlter.getText();
                System.out.println("teste do produto " + pdt);
                //lista.set(lista.getSelectedIndex(), valor+"- "+prodAlter, null);
                lista.set(lista.getSelectedIndex(), valor + "- " + pdt, null);
                switchDisplayable(null, getLista());//GEN-LINE:|7-commandAction|2|141-postAction
                // write post-action user code here
            } else if (command == voltarAlterar) {//GEN-LINE:|7-commandAction|3|148-preAction
                // write pre-action user code here
                switchDisplayable(null, getLista());//GEN-LINE:|7-commandAction|4|148-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|5|81-preAction
        } else if (displayable == formConta) {
            if (command == enviarConta) {//GEN-END:|7-commandAction|5|81-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|6|81-postAction
                // write post-action user code here
            } else if (command == voltarConta) {//GEN-LINE:|7-commandAction|7|83-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormInicio());//GEN-LINE:|7-commandAction|8|83-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|9|119-preAction
        } else if (displayable == formEnviar) {
            if (command == alterarQuantidade) {//GEN-END:|7-commandAction|9|119-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|10|119-postAction
                // write post-action user code here
            } else if (command == enviarProduto) {//GEN-LINE:|7-commandAction|11|113-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|12|113-postAction
                // write post-action user code here
            } else if (command == excluirProduto) {//GEN-LINE:|7-commandAction|13|121-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|14|121-postAction
                // write post-action user code here
            } else if (command == voltarEnviar1) {//GEN-LINE:|7-commandAction|15|115-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormVendas());//GEN-LINE:|7-commandAction|16|115-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|17|31-preAction
        } else if (displayable == formInicio) {
            if (command == ok) {//GEN-END:|7-commandAction|17|31-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormMesa());//GEN-LINE:|7-commandAction|18|31-postAction
                // write post-action user code here
            } else if (command == voltarInicio) {//GEN-LINE:|7-commandAction|19|61-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormLogin());//GEN-LINE:|7-commandAction|20|61-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|21|19-preAction
        } else if (displayable == formLogin) {
            if (command == exitCommand) {//GEN-END:|7-commandAction|21|19-preAction
                // write pre-action user code here
                exitMIDlet();//GEN-LINE:|7-commandAction|22|19-postAction
                // write post-action user code here
            } else if (command == login) {//GEN-LINE:|7-commandAction|23|25-preAction
                // write pre-action user code here

                alertaLogin = new Alert("Alerta", "Garçon ou Senha não existe", null, AlertType.WARNING);
                alertaGarSen = new Alert("Alerta", "Garçon ou Senha não informados", null, AlertType.WARNING);
                /*    if ((!numeroGarcon.getString().equals("")) & !senhaGarcon.getString().equals("")){
                try {
                if (isValidar(numeroGarcon.getString(),senhaGarcon.getString())) {
                switchDisplayable(null, getFormInicio());
                } else {switchDisplayable(null, alertaLogin);
                alertaGarSen.setTimeout(5000);
                numeroGarcon.setString("");
                senhaGarcon.setString("");
                }
                } catch (Exception ex) {
                System.out.println("Errado " + ex);
switchDisplayable (null, getFormInicio ());//GEN-LINE:|7-commandAction|24|25-postAction
                }
                } else {switchDisplayable(null, alertaGarSen);
                alertaGarSen.setTimeout(5000);
                numeroGarcon.setString("");
                senhaGarcon.setString("");
                }       */
                ServerSocketConnection ss = null;


                try {
                    boolean retorno = false;
                    SocketConnection connection = (SocketConnection) Connector.open("socket://10.0.30.107:3500");


                    // PrintStream output = new PrintStream(connection.openOutputStream());
                    //output.println("GET /my.html HTTP/0.9\n\n");
                    DataInputStream resp = connection.openDataInputStream();
                    DataOutputStream os = connection.openDataOutputStream();
                    String s = numeroGarcon.getString() + "," + senhaGarcon.getString();
                    os.writeUTF(s);
                    os.flush();

                    //while (retorno.equals("")) {
                    //  System.out.println("chegou ");

                    retorno = resp.readBoolean();
                    if (retorno) {
                        System.out.println(retorno);
                        switchDisplayable(null, getFormInicio());
                    } else {
                        switchDisplayable(null, alertaLogin);
                        alertaGarSen.setTimeout(5000);
                        numeroGarcon.setString("");
                        senhaGarcon.setString("");
                    }

                    //output.println(o);
                    //output.println(numeroGarcon.getString()+","+senhaGarcon.getString());
                    //output.flush();
                    // InputStream in = connection.openInputStream();
                   /* int ch;
                    while ((ch = in.read()) != -1) {
                    System.out.print((char) ch);
                    }*/
                    //in.close();
                    //output.close();


                    connection.close();
                    os.close();

                } catch (ConnectionNotFoundException error) {
                    Alert alert = new Alert(
                            "Error", "socket não acessado", null, AlertType.WARNING);
                    alert.setTimeout(Alert.FOREVER);
                    alert.setType(AlertType.ERROR);
                    switchDisplayable(null, alert);
                    //display.setCurrent(alert);
                } catch (IOException error) {
                    Alert alert = new Alert("Error", error.toString(), null, null);
                    alert.setTimeout(Alert.FOREVER);
                    alert.setType(AlertType.ERROR);
                    switchDisplayable(null, alert);
                    //display.setCurrent(alert);
                } finally {
                }

                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|25|41-preAction
        } else if (displayable == formMesa) {
            if (command == entrarMesa) {//GEN-END:|7-commandAction|25|41-preAction
                // write pre-action user code here
                alertaMesa = new Alert("Alerta", "Mesa não informada", null, AlertType.WARNING);
                if (!mesa.getString().equals("")) {
                    switchDisplayable(null, getFormVendas());//GEN-LINE:|7-commandAction|26|41-postAction
                    // write post-action user code here
                } else {
                    switchDisplayable(null, alertaMesa);
                    alertaMesa.setTimeout(5000);
                }
            } else if (command == voltarMesa) {//GEN-LINE:|7-commandAction|27|43-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormInicio());//GEN-LINE:|7-commandAction|28|43-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|29|88-preAction
        } else if (displayable == formParcial) {
            if (command == enviarParcial) {//GEN-END:|7-commandAction|29|88-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|30|88-postAction
                // write post-action user code here
            } else if (command == voltarParcial) {//GEN-LINE:|7-commandAction|31|90-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormInicio());//GEN-LINE:|7-commandAction|32|90-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|33|55-preAction
        } else if (displayable == formVendas) {
            if (command == adicionarProduto) {//GEN-END:|7-commandAction|33|55-preAction
                // write pre-action user code here
                alertaCodigo = new Alert("Alerta", "Código Inválido", null, AlertType.WARNING);
                alertaProduto = new Alert("Alerta", "Informar Produto", null, AlertType.WARNING);
                alertaQtd = new Alert("Alerta", "Informar Quantidade", null, AlertType.WARNING);
                // String p[]=new String [10];
                // String q[]=new String [10];

                if (!produto.getString().equals("")) {
                    if (!qtd.getString().equals("")) {
                        String nomeProd = codigos(produto.getString());
                        if (!nomeProd.equals("falso")) {
                            p[j] += nomeProd;
                            q[j] += qtd.getString();
                            j++;
                            //total++;
                            addProduto += nomeProd + "   " + qtd.getString() + "\n";
                            //addProduto+=codigos(produto.getString())+"   "+qtd.getString()+"\n";
                            p1.setText(addProduto);
                            produto.setString("");
                            qtd.setString("");
                        } else {
                            switchDisplayable(null, alertaCodigo);
                            alertaCodigo.setTimeout(5000);
                            produto.setString("");
                            qtd.setString("");
                        }
                    } else {
                        switchDisplayable(null, alertaQtd);
                        alertaCodigo.setTimeout(5000);
                        produto.setString("");
                        qtd.setString("");
                    }
                } else {
                    switchDisplayable(null, alertaProduto);
                    alertaCodigo.setTimeout(5000);
                    produto.setString("");
                    qtd.setString("");
                }
                // total=i;
//GEN-LINE:|7-commandAction|34|55-postAction
                // write post-action user code here
            } else if (command == finalizarVendas) {//GEN-LINE:|7-commandAction|35|57-preAction
                // write pre-action user code here
                switchDisplayable(null, getLista());//GEN-LINE:|7-commandAction|36|57-postAction
                // write post-action user code here
               /* String s="";
                for (int i=0;i<total;i++)
                s+=p[i]+"   "+q[i]+"\n";
                p2.setText(s);
                 * 
                 */
                for (int i = 0; i < j; i++) {
                    lista.insert(i, q[i] + "- " + p[i], null);
                }
                //p2.setText(produto.getString()+"   "+qtd.getString()+"\n");

            } else if (command == voltarVendas) {//GEN-LINE:|7-commandAction|37|59-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormMesa());//GEN-LINE:|7-commandAction|38|59-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|39|133-preAction
        } else if (displayable == lista) {
            if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|39|133-preAction
                // write pre-action user code here
                listaAction();//GEN-LINE:|7-commandAction|40|133-postAction
                // write post-action user code here
            } else if (command == alterar) {//GEN-LINE:|7-commandAction|41|143-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormAlterar());//GEN-LINE:|7-commandAction|42|143-postAction
                // write post-action user code here
            } else if (command == excluir) {//GEN-LINE:|7-commandAction|43|145-preAction
                // write pre-action user code here
                lista.delete(lista.getSelectedIndex());
//GEN-LINE:|7-commandAction|44|145-postAction
                // write post-action user code here
            } else if (command == voltarLista) {//GEN-LINE:|7-commandAction|45|137-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormVendas());//GEN-LINE:|7-commandAction|46|137-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|47|7-postCommandAction
        }//GEN-END:|7-commandAction|47|7-postCommandAction
        // write post-action user code here
    }//GEN-BEGIN:|7-commandAction|48|
    //</editor-fold>//GEN-END:|7-commandAction|48|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand ">//GEN-BEGIN:|18-getter|0|18-preInit
    /**
     * Returns an initiliazed instance of exitCommand component.
     * @return the initialized component instance
     */
    public Command getExitCommand() {
        if (exitCommand == null) {//GEN-END:|18-getter|0|18-preInit
            // write pre-init user code here
            exitCommand = new Command("Sair", Command.EXIT, 0);//GEN-LINE:|18-getter|1|18-postInit
            // write post-init user code here
        }//GEN-BEGIN:|18-getter|2|
        return exitCommand;
    }
    //</editor-fold>//GEN-END:|18-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: formLogin ">//GEN-BEGIN:|14-getter|0|14-preInit
    /**
     * Returns an initiliazed instance of formLogin component.
     * @return the initialized component instance
     */
    public Form getFormLogin() {
        if (formLogin == null) {//GEN-END:|14-getter|0|14-preInit
            // write pre-init user code here
            formLogin = new Form("Login", new Item[] { getNumeroGarcon(), getSenhaGarcon() });//GEN-BEGIN:|14-getter|1|14-postInit
            formLogin.addCommand(getExitCommand());
            formLogin.addCommand(getLogin());
            formLogin.setCommandListener(this);//GEN-END:|14-getter|1|14-postInit
            // write post-init user code here
        }//GEN-BEGIN:|14-getter|2|
        return formLogin;
    }
    //</editor-fold>//GEN-END:|14-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: login ">//GEN-BEGIN:|24-getter|0|24-preInit
    /**
     * Returns an initiliazed instance of login component.
     * @return the initialized component instance
     */
    public Command getLogin() {
        if (login == null) {//GEN-END:|24-getter|0|24-preInit
            // write pre-init user code here
            login = new Command("Entrar", Command.OK, 0);//GEN-LINE:|24-getter|1|24-postInit
            // write post-init user code here
        }//GEN-BEGIN:|24-getter|2|
        return login;
    }
    //</editor-fold>//GEN-END:|24-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: numeroGarcon ">//GEN-BEGIN:|22-getter|0|22-preInit
    /**
     * Returns an initiliazed instance of numeroGarcon component.
     * @return the initialized component instance
     */
    public TextField getNumeroGarcon() {
        if (numeroGarcon == null) {//GEN-END:|22-getter|0|22-preInit
            // write pre-init user code here
            numeroGarcon = new TextField("Gar\u00E7on", null, 5, TextField.NUMERIC);//GEN-LINE:|22-getter|1|22-postInit
            // write post-init user code here
        }//GEN-BEGIN:|22-getter|2|
        return numeroGarcon;
    }
    //</editor-fold>//GEN-END:|22-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: senhaGarcon ">//GEN-BEGIN:|23-getter|0|23-preInit
    /**
     * Returns an initiliazed instance of senhaGarcon component.
     * @return the initialized component instance
     */
    public TextField getSenhaGarcon() {
        if (senhaGarcon == null) {//GEN-END:|23-getter|0|23-preInit
            // write pre-init user code here
            senhaGarcon = new TextField("Senha", null, 5, TextField.ANY);//GEN-LINE:|23-getter|1|23-postInit
            // write post-init user code here
        }//GEN-BEGIN:|23-getter|2|
        return senhaGarcon;
    }
    //</editor-fold>//GEN-END:|23-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: formInicio ">//GEN-BEGIN:|28-getter|0|28-preInit
    /**
     * Returns an initiliazed instance of formInicio component.
     * @return the initialized component instance
     */
    public Form getFormInicio() {
        if (formInicio == null) {//GEN-END:|28-getter|0|28-preInit
            // write pre-init user code here
            formInicio = new Form("Gar\u00E7on Vendas", new Item[] { getNumGarcon1(), getFazerPedido(), getFecharConta(), getFecharParcial() });//GEN-BEGIN:|28-getter|1|28-postInit
            formInicio.addCommand(getOk());
            formInicio.addCommand(getVoltarInicio());
            formInicio.setCommandListener(this);//GEN-END:|28-getter|1|28-postInit
            // write post-init user code here
        }//GEN-BEGIN:|28-getter|2|
        return formInicio;
    }
    //</editor-fold>//GEN-END:|28-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: ticker ">//GEN-BEGIN:|27-getter|0|27-preInit
    /**
     * Returns an initiliazed instance of ticker component.
     * @return the initialized component instance
     */
    public Ticker getTicker() {
        if (ticker == null) {//GEN-END:|27-getter|0|27-preInit
            // write pre-init user code here
            ticker = new Ticker("");//GEN-LINE:|27-getter|1|27-postInit
            // write post-init user code here
        }//GEN-BEGIN:|27-getter|2|
        return ticker;
    }
    //</editor-fold>//GEN-END:|27-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: ok ">//GEN-BEGIN:|30-getter|0|30-preInit
    /**
     * Returns an initiliazed instance of ok component.
     * @return the initialized component instance
     */
    public Command getOk() {
        if (ok == null) {//GEN-END:|30-getter|0|30-preInit
            // write pre-init user code here
            ok = new Command("Ok", Command.OK, 0);//GEN-LINE:|30-getter|1|30-postInit
            // write post-init user code here
        }//GEN-BEGIN:|30-getter|2|
        return ok;
    }
    //</editor-fold>//GEN-END:|30-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: formMesa ">//GEN-BEGIN:|29-getter|0|29-preInit
    /**
     * Returns an initiliazed instance of formMesa component.
     * @return the initialized component instance
     */
    public Form getFormMesa() {
        if (formMesa == null) {//GEN-END:|29-getter|0|29-preInit
            // write pre-init user code here
            formMesa = new Form("Gar\u00E7on Vendas", new Item[] { getNumGarcon2(), getMesa() });//GEN-BEGIN:|29-getter|1|29-postInit
            formMesa.addCommand(getEntrarMesa());
            formMesa.addCommand(getVoltarMesa());
            formMesa.setCommandListener(this);//GEN-END:|29-getter|1|29-postInit
            // write post-init user code here
        }//GEN-BEGIN:|29-getter|2|
        return formMesa;
    }
    //</editor-fold>//GEN-END:|29-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: numGarcon1 ">//GEN-BEGIN:|33-getter|0|33-preInit
    /**
     * Returns an initiliazed instance of numGarcon1 component.
     * @return the initialized component instance
     */
    public StringItem getNumGarcon1() {
        if (numGarcon1 == null) {//GEN-END:|33-getter|0|33-preInit
            // write pre-init user code here
            String g = numeroGarcon.getString();
            numGarcon1 = new StringItem("Gar\u00E7on: ", null);//GEN-LINE:|33-getter|1|33-postInit
            // write post-init user code here
            numGarcon1 = new StringItem("Gar\u00E7on: " + g, null);
        }//GEN-BEGIN:|33-getter|2|
        return numGarcon1;
    }
    //</editor-fold>//GEN-END:|33-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: fecharConta ">//GEN-BEGIN:|35-getter|0|35-preInit
    /**
     * Returns an initiliazed instance of fecharConta component.
     * @return the initialized component instance
     */
    public StringItem getFecharConta() {
        if (fecharConta == null) {//GEN-END:|35-getter|0|35-preInit
            // write pre-init user code here
            fecharConta = new StringItem(" ", "Fechar Conta", Item.HYPERLINK);//GEN-BEGIN:|35-getter|1|35-postInit
            fecharConta.addCommand(getOkEntrar());
            fecharConta.setItemCommandListener(this);
            fecharConta.setDefaultCommand(getOkEntrar());//GEN-END:|35-getter|1|35-postInit
            // write post-init user code here
        }//GEN-BEGIN:|35-getter|2|
        return fecharConta;
    }
    //</editor-fold>//GEN-END:|35-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: numGarcon2 ">//GEN-BEGIN:|37-getter|0|37-preInit
    /**
     * Returns an initiliazed instance of numGarcon2 component.
     * @return the initialized component instance
     */
    public StringItem getNumGarcon2() {
        if (numGarcon2 == null) {//GEN-END:|37-getter|0|37-preInit
            // write pre-init user code here
            String g = numeroGarcon.getString();
            numGarcon2 = new StringItem("Gar\u00E7on: ", null);//GEN-LINE:|37-getter|1|37-postInit
            // write post-init user code here
            numGarcon2 = new StringItem("Gar\u00E7on: " + g, null);
        }//GEN-BEGIN:|37-getter|2|
        return numGarcon2;
    }
    //</editor-fold>//GEN-END:|37-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: mesa ">//GEN-BEGIN:|38-getter|0|38-preInit
    /**
     * Returns an initiliazed instance of mesa component.
     * @return the initialized component instance
     */
    public TextField getMesa() {
        if (mesa == null) {//GEN-END:|38-getter|0|38-preInit
            // write pre-init user code here
            mesa = new TextField("Mesa:", null, 10, TextField.ANY);//GEN-LINE:|38-getter|1|38-postInit
            // write post-init user code here
        }//GEN-BEGIN:|38-getter|2|
        return mesa;
    }
    //</editor-fold>//GEN-END:|38-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: entrarMesa ">//GEN-BEGIN:|40-getter|0|40-preInit
    /**
     * Returns an initiliazed instance of entrarMesa component.
     * @return the initialized component instance
     */
    public Command getEntrarMesa() {
        if (entrarMesa == null) {//GEN-END:|40-getter|0|40-preInit
            // write pre-init user code here
            entrarMesa = new Command("Entrar", Command.OK, 0);//GEN-LINE:|40-getter|1|40-postInit
            // write post-init user code here
        }//GEN-BEGIN:|40-getter|2|
        return entrarMesa;
    }
    //</editor-fold>//GEN-END:|40-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarMesa ">//GEN-BEGIN:|42-getter|0|42-preInit
    /**
     * Returns an initiliazed instance of voltarMesa component.
     * @return the initialized component instance
     */
    public Command getVoltarMesa() {
        if (voltarMesa == null) {//GEN-END:|42-getter|0|42-preInit
            // write pre-init user code here
            voltarMesa = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|42-getter|1|42-postInit
            // write post-init user code here
        }//GEN-BEGIN:|42-getter|2|
        return voltarMesa;
    }
    //</editor-fold>//GEN-END:|42-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand1 ">//GEN-BEGIN:|44-getter|0|44-preInit
    /**
     * Returns an initiliazed instance of exitCommand1 component.
     * @return the initialized component instance
     */
    public Command getExitCommand1() {
        if (exitCommand1 == null) {//GEN-END:|44-getter|0|44-preInit
            // write pre-init user code here
            exitCommand1 = new Command("Sair", Command.EXIT, 0);//GEN-LINE:|44-getter|1|44-postInit
            // write post-init user code here
        }//GEN-BEGIN:|44-getter|2|
        return exitCommand1;
    }
    //</editor-fold>//GEN-END:|44-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: formVendas ">//GEN-BEGIN:|48-getter|0|48-preInit
    /**
     * Returns an initiliazed instance of formVendas component.
     * @return the initialized component instance
     */
    public Form getFormVendas() {
        if (formVendas == null) {//GEN-END:|48-getter|0|48-preInit
            // write pre-init user code here
            formVendas = new Form("Gar\u00E7on Vendas", new Item[] { getNumMesaVend(), getProduto(), getQtd(), getP1() });//GEN-BEGIN:|48-getter|1|48-postInit
            formVendas.addCommand(getAdicionarProduto());
            formVendas.addCommand(getFinalizarVendas());
            formVendas.addCommand(getVoltarVendas());
            formVendas.setCommandListener(this);//GEN-END:|48-getter|1|48-postInit
            // write post-init user code here
        }//GEN-BEGIN:|48-getter|2|
        return formVendas;
    }
    //</editor-fold>//GEN-END:|48-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: numMesaVend ">//GEN-BEGIN:|51-getter|0|51-preInit
    /**
     * Returns an initiliazed instance of numMesaVend component.
     * @return the initialized component instance
     */
    public StringItem getNumMesaVend() {
        if (numMesaVend == null) {//GEN-END:|51-getter|0|51-preInit
            // write pre-init user code here
            String m = mesa.getString();
            numMesaVend = new StringItem("Mesa: ", null);//GEN-LINE:|51-getter|1|51-postInit
            // write post-init user code here
            numMesaVend = new StringItem("Mesa: " + m, null);
        }//GEN-BEGIN:|51-getter|2|
        return numMesaVend;
    }
    //</editor-fold>//GEN-END:|51-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: produto ">//GEN-BEGIN:|52-getter|0|52-preInit
    /**
     * Returns an initiliazed instance of produto component.
     * @return the initialized component instance
     */
    public TextField getProduto() {
        if (produto == null) {//GEN-END:|52-getter|0|52-preInit
            // write pre-init user code here
            produto = new TextField("Produto", null, 10, TextField.NUMERIC);//GEN-LINE:|52-getter|1|52-postInit
            // write post-init user code here
        }//GEN-BEGIN:|52-getter|2|
        return produto;
    }
    //</editor-fold>//GEN-END:|52-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: qtd ">//GEN-BEGIN:|53-getter|0|53-preInit
    /**
     * Returns an initiliazed instance of qtd component.
     * @return the initialized component instance
     */
    public TextField getQtd() {
        if (qtd == null) {//GEN-END:|53-getter|0|53-preInit
            // write pre-init user code here
            qtd = new TextField("Quantidade", null, 10, TextField.NUMERIC);//GEN-LINE:|53-getter|1|53-postInit
            // write post-init user code here
        }//GEN-BEGIN:|53-getter|2|
        return qtd;
    }
    //</editor-fold>//GEN-END:|53-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: adicionarProduto ">//GEN-BEGIN:|54-getter|0|54-preInit
    /**
     * Returns an initiliazed instance of adicionarProduto component.
     * @return the initialized component instance
     */
    public Command getAdicionarProduto() {
        if (adicionarProduto == null) {//GEN-END:|54-getter|0|54-preInit
            // write pre-init user code here
            adicionarProduto = new Command("adicionar", Command.OK, 0);//GEN-LINE:|54-getter|1|54-postInit
            // write post-init user code here
        }//GEN-BEGIN:|54-getter|2|
        return adicionarProduto;
    }
    //</editor-fold>//GEN-END:|54-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: finalizarVendas ">//GEN-BEGIN:|56-getter|0|56-preInit
    /**
     * Returns an initiliazed instance of finalizarVendas component.
     * @return the initialized component instance
     */
    public Command getFinalizarVendas() {
        if (finalizarVendas == null) {//GEN-END:|56-getter|0|56-preInit
            // write pre-init user code here
            finalizarVendas = new Command("finalizar", Command.OK, 0);//GEN-LINE:|56-getter|1|56-postInit
            // write post-init user code here
        }//GEN-BEGIN:|56-getter|2|
        return finalizarVendas;
    }
    //</editor-fold>//GEN-END:|56-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarVendas ">//GEN-BEGIN:|58-getter|0|58-preInit
    /**
     * Returns an initiliazed instance of voltarVendas component.
     * @return the initialized component instance
     */
    public Command getVoltarVendas() {
        if (voltarVendas == null) {//GEN-END:|58-getter|0|58-preInit
            // write pre-init user code here
            voltarVendas = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|58-getter|1|58-postInit
            // write post-init user code here
        }//GEN-BEGIN:|58-getter|2|
        return voltarVendas;
    }
    //</editor-fold>//GEN-END:|58-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarInicio ">//GEN-BEGIN:|60-getter|0|60-preInit
    /**
     * Returns an initiliazed instance of voltarInicio component.
     * @return the initialized component instance
     */
    public Command getVoltarInicio() {
        if (voltarInicio == null) {//GEN-END:|60-getter|0|60-preInit
            // write pre-init user code here
            voltarInicio = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|60-getter|1|60-postInit
            // write post-init user code here
        }//GEN-BEGIN:|60-getter|2|
        return voltarInicio;
    }
    //</editor-fold>//GEN-END:|60-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: fecharParcial ">//GEN-BEGIN:|64-getter|0|64-preInit
    /**
     * Returns an initiliazed instance of fecharParcial component.
     * @return the initialized component instance
     */
    public StringItem getFecharParcial() {
        if (fecharParcial == null) {//GEN-END:|64-getter|0|64-preInit
            // write pre-init user code here
            fecharParcial = new StringItem(" ", "Fechar Parcial", Item.HYPERLINK);//GEN-BEGIN:|64-getter|1|64-postInit
            fecharParcial.addCommand(getOkEntrar());
            fecharParcial.setItemCommandListener(this);
            fecharParcial.setDefaultCommand(getOkEntrar());//GEN-END:|64-getter|1|64-postInit
            // write post-init user code here
        }//GEN-BEGIN:|64-getter|2|
        return fecharParcial;
    }
    //</editor-fold>//GEN-END:|64-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Items ">//GEN-BEGIN:|17-itemCommandAction|0|17-preItemCommandAction
    /**
     * Called by a system to indicated that a command has been invoked on a particular item.
     * @param command the Command that was invoked
     * @param displayable the Item where the command was invoked
     */
    public void commandAction(Command command, Item item) {//GEN-END:|17-itemCommandAction|0|17-preItemCommandAction
        // write pre-action user code here
        if (item == fazerPedido) {//GEN-BEGIN:|17-itemCommandAction|1|94-preAction
            if (command == okEntrar) {//GEN-END:|17-itemCommandAction|1|94-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormMesa());//GEN-LINE:|17-itemCommandAction|2|94-postAction
                // write post-action user code here
            }//GEN-BEGIN:|17-itemCommandAction|3|70-preAction
        } else if (item == fecharConta) {
            if (command == okEntrar) {//GEN-END:|17-itemCommandAction|3|70-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormConta());//GEN-LINE:|17-itemCommandAction|4|70-postAction
                // write post-action user code here
            }//GEN-BEGIN:|17-itemCommandAction|5|74-preAction
        } else if (item == fecharParcial) {
            if (command == okEntrar) {//GEN-END:|17-itemCommandAction|5|74-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormParcial());//GEN-LINE:|17-itemCommandAction|6|74-postAction
                // write post-action user code here
            }//GEN-BEGIN:|17-itemCommandAction|7|122-preAction
        } else if (item == p2) {
            if (command == alterarQuantidade) {//GEN-END:|17-itemCommandAction|7|122-preAction
                // write pre-action user code here
//GEN-LINE:|17-itemCommandAction|8|122-postAction
                // write post-action user code here
            } else if (command == excluirProduto) {//GEN-LINE:|17-itemCommandAction|9|123-preAction
                // write pre-action user code here
//GEN-LINE:|17-itemCommandAction|10|123-postAction
                // write post-action user code here
            }//GEN-BEGIN:|17-itemCommandAction|11|17-postItemCommandAction
        }//GEN-END:|17-itemCommandAction|11|17-postItemCommandAction
        // write post-action user code here
    }//GEN-BEGIN:|17-itemCommandAction|12|
    //</editor-fold>//GEN-END:|17-itemCommandAction|12|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okEntrar ">//GEN-BEGIN:|67-getter|0|67-preInit
    /**
     * Returns an initiliazed instance of okEntrar component.
     * @return the initialized component instance
     */
    public Command getOkEntrar() {
        if (okEntrar == null) {//GEN-END:|67-getter|0|67-preInit
            // write pre-init user code here
            okEntrar = new Command("Ok", "Entrar", Command.OK, 0);//GEN-LINE:|67-getter|1|67-postInit
            // write post-init user code here
        }//GEN-BEGIN:|67-getter|2|
        return okEntrar;
    }
    //</editor-fold>//GEN-END:|67-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: formConta ">//GEN-BEGIN:|65-getter|0|65-preInit
    /**
     * Returns an initiliazed instance of formConta component.
     * @return the initialized component instance
     */
    public Form getFormConta() {
        if (formConta == null) {//GEN-END:|65-getter|0|65-preInit
            // write pre-init user code here
            formConta = new Form("Gar\u00E7on Vendas", new Item[] { getGarconConta(), getMesaConta(), getPessoasConta() });//GEN-BEGIN:|65-getter|1|65-postInit
            formConta.addCommand(getEnviarConta());
            formConta.addCommand(getVoltarConta());
            formConta.setCommandListener(this);//GEN-END:|65-getter|1|65-postInit
            // write post-init user code here
        }//GEN-BEGIN:|65-getter|2|
        return formConta;
    }
    //</editor-fold>//GEN-END:|65-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: formParcial ">//GEN-BEGIN:|66-getter|0|66-preInit
    /**
     * Returns an initiliazed instance of formParcial component.
     * @return the initialized component instance
     */
    public Form getFormParcial() {
        if (formParcial == null) {//GEN-END:|66-getter|0|66-preInit
            // write pre-init user code here
            formParcial = new Form("Gar\u00E7on Vendas", new Item[] { getGarconParcial(), getMesaParcial() });//GEN-BEGIN:|66-getter|1|66-postInit
            formParcial.addCommand(getEnviarParcial());
            formParcial.addCommand(getVoltarParcial());
            formParcial.setCommandListener(this);//GEN-END:|66-getter|1|66-postInit
            // write post-init user code here
        }//GEN-BEGIN:|66-getter|2|
        return formParcial;
    }
    //</editor-fold>//GEN-END:|66-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: enviarConta ">//GEN-BEGIN:|80-getter|0|80-preInit
    /**
     * Returns an initiliazed instance of enviarConta component.
     * @return the initialized component instance
     */
    public Command getEnviarConta() {
        if (enviarConta == null) {//GEN-END:|80-getter|0|80-preInit
            // write pre-init user code here
            enviarConta = new Command("Enviar", Command.OK, 0);//GEN-LINE:|80-getter|1|80-postInit
            // write post-init user code here
        }//GEN-BEGIN:|80-getter|2|
        return enviarConta;
    }
    //</editor-fold>//GEN-END:|80-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarConta ">//GEN-BEGIN:|82-getter|0|82-preInit
    /**
     * Returns an initiliazed instance of voltarConta component.
     * @return the initialized component instance
     */
    public Command getVoltarConta() {
        if (voltarConta == null) {//GEN-END:|82-getter|0|82-preInit
            // write pre-init user code here
            voltarConta = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|82-getter|1|82-postInit
            // write post-init user code here
        }//GEN-BEGIN:|82-getter|2|
        return voltarConta;
    }
    //</editor-fold>//GEN-END:|82-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: garconConta ">//GEN-BEGIN:|77-getter|0|77-preInit
    /**
     * Returns an initiliazed instance of garconConta component.
     * @return the initialized component instance
     */
    public TextField getGarconConta() {
        if (garconConta == null) {//GEN-END:|77-getter|0|77-preInit
            // write pre-init user code here
            garconConta = new TextField("Gar\u00E7on: ", null, 32, TextField.NUMERIC);//GEN-LINE:|77-getter|1|77-postInit
            // write post-init user code here
        }//GEN-BEGIN:|77-getter|2|
        return garconConta;
    }
    //</editor-fold>//GEN-END:|77-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: mesaConta ">//GEN-BEGIN:|78-getter|0|78-preInit
    /**
     * Returns an initiliazed instance of mesaConta component.
     * @return the initialized component instance
     */
    public TextField getMesaConta() {
        if (mesaConta == null) {//GEN-END:|78-getter|0|78-preInit
            // write pre-init user code here
            mesaConta = new TextField("Mesa: ", null, 32, TextField.NUMERIC);//GEN-LINE:|78-getter|1|78-postInit
            // write post-init user code here
        }//GEN-BEGIN:|78-getter|2|
        return mesaConta;
    }
    //</editor-fold>//GEN-END:|78-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: pessoasConta ">//GEN-BEGIN:|79-getter|0|79-preInit
    /**
     * Returns an initiliazed instance of pessoasConta component.
     * @return the initialized component instance
     */
    public TextField getPessoasConta() {
        if (pessoasConta == null) {//GEN-END:|79-getter|0|79-preInit
            // write pre-init user code here
            pessoasConta = new TextField("Pessoas: ", null, 32, TextField.NUMERIC);//GEN-LINE:|79-getter|1|79-postInit
            // write post-init user code here
        }//GEN-BEGIN:|79-getter|2|
        return pessoasConta;
    }
    //</editor-fold>//GEN-END:|79-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: enviarParcial ">//GEN-BEGIN:|87-getter|0|87-preInit
    /**
     * Returns an initiliazed instance of enviarParcial component.
     * @return the initialized component instance
     */
    public Command getEnviarParcial() {
        if (enviarParcial == null) {//GEN-END:|87-getter|0|87-preInit
            // write pre-init user code here
            enviarParcial = new Command("Enviar", Command.OK, 0);//GEN-LINE:|87-getter|1|87-postInit
            // write post-init user code here
        }//GEN-BEGIN:|87-getter|2|
        return enviarParcial;
    }
    //</editor-fold>//GEN-END:|87-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarParcial ">//GEN-BEGIN:|89-getter|0|89-preInit
    /**
     * Returns an initiliazed instance of voltarParcial component.
     * @return the initialized component instance
     */
    public Command getVoltarParcial() {
        if (voltarParcial == null) {//GEN-END:|89-getter|0|89-preInit
            // write pre-init user code here
            voltarParcial = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|89-getter|1|89-postInit
            // write post-init user code here
        }//GEN-BEGIN:|89-getter|2|
        return voltarParcial;
    }
    //</editor-fold>//GEN-END:|89-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: garconParcial ">//GEN-BEGIN:|85-getter|0|85-preInit
    /**
     * Returns an initiliazed instance of garconParcial component.
     * @return the initialized component instance
     */
    public TextField getGarconParcial() {
        if (garconParcial == null) {//GEN-END:|85-getter|0|85-preInit
            // write pre-init user code here
            garconParcial = new TextField("Gar\u00E7on: ", null, 32, TextField.NUMERIC);//GEN-LINE:|85-getter|1|85-postInit
            // write post-init user code here
        }//GEN-BEGIN:|85-getter|2|
        return garconParcial;
    }
    //</editor-fold>//GEN-END:|85-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: mesaParcial ">//GEN-BEGIN:|86-getter|0|86-preInit
    /**
     * Returns an initiliazed instance of mesaParcial component.
     * @return the initialized component instance
     */
    public TextField getMesaParcial() {
        if (mesaParcial == null) {//GEN-END:|86-getter|0|86-preInit
            // write pre-init user code here
            mesaParcial = new TextField("Mesa: ", null, 32, TextField.NUMERIC);//GEN-LINE:|86-getter|1|86-postInit
            // write post-init user code here
        }//GEN-BEGIN:|86-getter|2|
        return mesaParcial;
    }
    //</editor-fold>//GEN-END:|86-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: fazerPedido ">//GEN-BEGIN:|93-getter|0|93-preInit
    /**
     * Returns an initiliazed instance of fazerPedido component.
     * @return the initialized component instance
     */
    public StringItem getFazerPedido() {
        if (fazerPedido == null) {//GEN-END:|93-getter|0|93-preInit
            // write pre-init user code here
            fazerPedido = new StringItem(" ", "Fazer Pedidos", Item.HYPERLINK);//GEN-BEGIN:|93-getter|1|93-postInit
            fazerPedido.addCommand(getOkEntrar());
            fazerPedido.setItemCommandListener(this);
            fazerPedido.setDefaultCommand(getOkEntrar());//GEN-END:|93-getter|1|93-postInit
            // write post-init user code here
        }//GEN-BEGIN:|93-getter|2|
        return fazerPedido;
    }
    //</editor-fold>//GEN-END:|93-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: itemCommand ">//GEN-BEGIN:|96-getter|0|96-preInit
    /**
     * Returns an initiliazed instance of itemCommand component.
     * @return the initialized component instance
     */
    public Command getItemCommand() {
        if (itemCommand == null) {//GEN-END:|96-getter|0|96-preInit
            // write pre-init user code here
            itemCommand = new Command("Item", Command.ITEM, 0);//GEN-LINE:|96-getter|1|96-postInit
            // write post-init user code here
        }//GEN-BEGIN:|96-getter|2|
        return itemCommand;
    }
    //</editor-fold>//GEN-END:|96-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: p1 ">//GEN-BEGIN:|98-getter|0|98-preInit
    /**
     * Returns an initiliazed instance of p1 component.
     * @return the initialized component instance
     */
    public StringItem getP1() {
        if (p1 == null) {//GEN-END:|98-getter|0|98-preInit
            // write pre-init user code here
            p1 = new StringItem("", null);//GEN-LINE:|98-getter|1|98-postInit
            // write post-init user code here
        }//GEN-BEGIN:|98-getter|2|
        return p1;
    }
    //</editor-fold>//GEN-END:|98-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand ">//GEN-BEGIN:|107-getter|0|107-preInit
    /**
     * Returns an initiliazed instance of okCommand component.
     * @return the initialized component instance
     */
    public Command getOkCommand() {
        if (okCommand == null) {//GEN-END:|107-getter|0|107-preInit
            // write pre-init user code here
            okCommand = new Command("Ok", Command.OK, 0);//GEN-LINE:|107-getter|1|107-postInit
            // write post-init user code here
        }//GEN-BEGIN:|107-getter|2|
        return okCommand;
    }
    //</editor-fold>//GEN-END:|107-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarEnviar ">//GEN-BEGIN:|109-getter|0|109-preInit
    /**
     * Returns an initiliazed instance of voltarEnviar component.
     * @return the initialized component instance
     */
    public Command getVoltarEnviar() {
        if (voltarEnviar == null) {//GEN-END:|109-getter|0|109-preInit
            // write pre-init user code here
            voltarEnviar = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|109-getter|1|109-postInit
            // write post-init user code here
        }//GEN-BEGIN:|109-getter|2|
        return voltarEnviar;
    }
    //</editor-fold>//GEN-END:|109-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: formEnviar ">//GEN-BEGIN:|105-getter|0|105-preInit
    /**
     * Returns an initiliazed instance of formEnviar component.
     * @return the initialized component instance
     */
    public Form getFormEnviar() {
        if (formEnviar == null) {//GEN-END:|105-getter|0|105-preInit
            // write pre-init user code here
            formEnviar = new Form("Gar\u00E7on Vendas", new Item[] { getP2() });//GEN-BEGIN:|105-getter|1|105-postInit
            formEnviar.addCommand(getEnviarProduto());
            formEnviar.addCommand(getVoltarEnviar1());
            formEnviar.addCommand(getAlterarQuantidade());
            formEnviar.addCommand(getExcluirProduto());
            formEnviar.setCommandListener(this);//GEN-END:|105-getter|1|105-postInit
            // write post-init user code here
        }//GEN-BEGIN:|105-getter|2|
        return formEnviar;
    }
    //</editor-fold>//GEN-END:|105-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: enviarProduto ">//GEN-BEGIN:|112-getter|0|112-preInit
    /**
     * Returns an initiliazed instance of enviarProduto component.
     * @return the initialized component instance
     */
    public Command getEnviarProduto() {
        if (enviarProduto == null) {//GEN-END:|112-getter|0|112-preInit
            // write pre-init user code here
            enviarProduto = new Command("Op\u00E7\u00F5es", Command.OK, 0);//GEN-LINE:|112-getter|1|112-postInit
            // write post-init user code here
        }//GEN-BEGIN:|112-getter|2|
        return enviarProduto;
    }
    //</editor-fold>//GEN-END:|112-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarEnviar1 ">//GEN-BEGIN:|114-getter|0|114-preInit
    /**
     * Returns an initiliazed instance of voltarEnviar1 component.
     * @return the initialized component instance
     */
    public Command getVoltarEnviar1() {
        if (voltarEnviar1 == null) {//GEN-END:|114-getter|0|114-preInit
            // write pre-init user code here
            voltarEnviar1 = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|114-getter|1|114-postInit
            // write post-init user code here
        }//GEN-BEGIN:|114-getter|2|
        return voltarEnviar1;
    }
    //</editor-fold>//GEN-END:|114-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: p2 ">//GEN-BEGIN:|117-getter|0|117-preInit
    /**
     * Returns an initiliazed instance of p2 component.
     * @return the initialized component instance
     */
    public StringItem getP2() {
        if (p2 == null) {//GEN-END:|117-getter|0|117-preInit
            // write pre-init user code here
            p2 = new StringItem("", null, Item.HYPERLINK);//GEN-BEGIN:|117-getter|1|117-postInit
            p2.addCommand(getAlterarQuantidade());
            p2.addCommand(getExcluirProduto());
            p2.setItemCommandListener(this);//GEN-END:|117-getter|1|117-postInit
            // write post-init user code here
        }//GEN-BEGIN:|117-getter|2|
        return p2;
    }
    //</editor-fold>//GEN-END:|117-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: alterarQuantidade ">//GEN-BEGIN:|118-getter|0|118-preInit
    /**
     * Returns an initiliazed instance of alterarQuantidade component.
     * @return the initialized component instance
     */
    public Command getAlterarQuantidade() {
        if (alterarQuantidade == null) {//GEN-END:|118-getter|0|118-preInit
            // write pre-init user code here
            alterarQuantidade = new Command("Alterar", Command.OK, 0);//GEN-LINE:|118-getter|1|118-postInit
            // write post-init user code here
        }//GEN-BEGIN:|118-getter|2|
        return alterarQuantidade;
    }
    //</editor-fold>//GEN-END:|118-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: excluirProduto ">//GEN-BEGIN:|120-getter|0|120-preInit
    /**
     * Returns an initiliazed instance of excluirProduto component.
     * @return the initialized component instance
     */
    public Command getExcluirProduto() {
        if (excluirProduto == null) {//GEN-END:|120-getter|0|120-preInit
            // write pre-init user code here
            excluirProduto = new Command("Excluir", Command.OK, 0);//GEN-LINE:|120-getter|1|120-postInit
            // write post-init user code here
        }//GEN-BEGIN:|120-getter|2|
        return excluirProduto;
    }
    //</editor-fold>//GEN-END:|120-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: formAlterar ">//GEN-BEGIN:|124-getter|0|124-preInit
    /**
     * Returns an initiliazed instance of formAlterar component.
     * @return the initialized component instance
     */
    public Form getFormAlterar() {
        if (formAlterar == null) {//GEN-END:|124-getter|0|124-preInit
            // write pre-init user code here
            formAlterar = new Form("Alterar Produto", new Item[] { getProdAlter(), getNewQtd() });//GEN-BEGIN:|124-getter|1|124-postInit
            formAlterar.addCommand(getAlterar1());
            formAlterar.addCommand(getVoltarAlterar());
            formAlterar.setCommandListener(this);//GEN-END:|124-getter|1|124-postInit
            // write post-init user code here
        }//GEN-BEGIN:|124-getter|2|
        return formAlterar;
    }
    //</editor-fold>//GEN-END:|124-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: prodAlter ">//GEN-BEGIN:|127-getter|0|127-preInit
    /**
     * Returns an initiliazed instance of prodAlter component.
     * @return the initialized component instance
     */
    public StringItem getProdAlter() {
        if (prodAlter == null) {//GEN-END:|127-getter|0|127-preInit
            // write pre-init user code here
            prodAlter = new StringItem("", null);//GEN-LINE:|127-getter|1|127-postInit
            // write post-init user code here
            prodAlter = new StringItem(lista.getString(lista.getSelectedIndex()).substring(2), null);

        }//GEN-BEGIN:|127-getter|2|
        return prodAlter;
    }
    //</editor-fold>//GEN-END:|127-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarLista ">//GEN-BEGIN:|136-getter|0|136-preInit
    /**
     * Returns an initiliazed instance of voltarLista component.
     * @return the initialized component instance
     */
    public Command getVoltarLista() {
        if (voltarLista == null) {//GEN-END:|136-getter|0|136-preInit
            // write pre-init user code here
            voltarLista = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|136-getter|1|136-postInit
            // write post-init user code here
        }//GEN-BEGIN:|136-getter|2|
        return voltarLista;
    }
    //</editor-fold>//GEN-END:|136-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: lista ">//GEN-BEGIN:|132-getter|0|132-preInit
    /**
     * Returns an initiliazed instance of lista component.
     * @return the initialized component instance
     */
    public List getLista() {
        if (lista == null) {//GEN-END:|132-getter|0|132-preInit
            // write pre-init user code here
            lista = new List("itens da comanda", Choice.IMPLICIT);//GEN-BEGIN:|132-getter|1|132-postInit
            lista.addCommand(getVoltarLista());
            lista.addCommand(getAlterar());
            lista.addCommand(getExcluir());
            lista.setCommandListener(this);//GEN-END:|132-getter|1|132-postInit
            // write post-init user code here
        }//GEN-BEGIN:|132-getter|2|
        return lista;
    }
    //</editor-fold>//GEN-END:|132-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: listaAction ">//GEN-BEGIN:|132-action|0|132-preAction
    /**
     * Performs an action assigned to the selected list element in the lista component.
     */
    public void listaAction() {//GEN-END:|132-action|0|132-preAction
        // enter pre-action user code here
        String __selectedString = getLista().getString(getLista().getSelectedIndex());//GEN-LINE:|132-action|1|132-postAction
        // enter post-action user code here
    }//GEN-BEGIN:|132-action|2|
    //</editor-fold>//GEN-END:|132-action|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: newQtd ">//GEN-BEGIN:|139-getter|0|139-preInit
    /**
     * Returns an initiliazed instance of newQtd component.
     * @return the initialized component instance
     */
    public TextField getNewQtd() {
        if (newQtd == null) {//GEN-END:|139-getter|0|139-preInit
            // write pre-init user code here
            newQtd = new TextField("Quantidade", null, 32, TextField.ANY);//GEN-LINE:|139-getter|1|139-postInit
            // write post-init user code here
            newQtd.setString(lista.getString(lista.getSelectedIndex()).substring(0, 1));
        }//GEN-BEGIN:|139-getter|2|
        return newQtd;
    }
    //</editor-fold>//GEN-END:|139-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: alterar1 ">//GEN-BEGIN:|140-getter|0|140-preInit
    /**
     * Returns an initiliazed instance of alterar1 component.
     * @return the initialized component instance
     */
    public Command getAlterar1() {
        if (alterar1 == null) {//GEN-END:|140-getter|0|140-preInit
            // write pre-init user code here
            alterar1 = new Command("Alterar", Command.OK, 0);//GEN-LINE:|140-getter|1|140-postInit
            // write post-init user code here
            pdt += "" + prodAlter.getText();

        }//GEN-BEGIN:|140-getter|2|
        return alterar1;
    }
    //</editor-fold>//GEN-END:|140-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: alterar ">//GEN-BEGIN:|142-getter|0|142-preInit
    /**
     * Returns an initiliazed instance of alterar component.
     * @return the initialized component instance
     */
    public Command getAlterar() {
        if (alterar == null) {//GEN-END:|142-getter|0|142-preInit
            // write pre-init user code here
            alterar = new Command("Alterar", Command.OK, 0);//GEN-LINE:|142-getter|1|142-postInit
            // write post-init user code here
        }//GEN-BEGIN:|142-getter|2|
        return alterar;
    }
    //</editor-fold>//GEN-END:|142-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: excluir ">//GEN-BEGIN:|144-getter|0|144-preInit
    /**
     * Returns an initiliazed instance of excluir component.
     * @return the initialized component instance
     */
    public Command getExcluir() {
        if (excluir == null) {//GEN-END:|144-getter|0|144-preInit
            // write pre-init user code here
            excluir = new Command("Excluir", Command.OK, 0);//GEN-LINE:|144-getter|1|144-postInit
            // write post-init user code here
        }//GEN-BEGIN:|144-getter|2|
        return excluir;
    }
    //</editor-fold>//GEN-END:|144-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarAlterar ">//GEN-BEGIN:|147-getter|0|147-preInit
    /**
     * Returns an initiliazed instance of voltarAlterar component.
     * @return the initialized component instance
     */
    public Command getVoltarAlterar() {
        if (voltarAlterar == null) {//GEN-END:|147-getter|0|147-preInit
            // write pre-init user code here
            voltarAlterar = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|147-getter|1|147-postInit
            // write post-init user code here
        }//GEN-BEGIN:|147-getter|2|
        return voltarAlterar;
    }
    //</editor-fold>//GEN-END:|147-getter|2|

    /**
     * Returns a display instance.
     * @return the display instance.
     */
    public Display getDisplay() {
        return Display.getDisplay(this);
    }

    /**
     * Exits MIDlet.
     */
    public void exitMIDlet() {
        switchDisplayable(null, null);
        destroyApp(true);
        notifyDestroyed();
    }

    /**
     * Called when MIDlet is started.
     * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
     */
    public void startApp() {
        if (midletPaused) {
            resumeMIDlet();
        } else {
            initialize();
            startMIDlet();
        }
        midletPaused = false;
    }

    /**
     * Called when MIDlet is paused.
     */
    public void pauseApp() {
        midletPaused = true;
    }

    /**
     * Called to signal the MIDlet to terminate.
     * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
     */
    public void destroyApp(boolean unconditional) {
    }
}
